﻿using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 渐变.admin_Form
{
    public partial class admin_complaintFrm : Form
    {
        public admin_complaintFrm()
        {
            InitializeComponent();
        }

        private void admin_complaintFrm_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
        }

        private void ucDataGridView1_Load(object sender, EventArgs e)
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "cid", HeadText = "编号", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carname", HeadText = "车名", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carid", HeadText = "车牌号", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carproblem", HeadText = "投诉内容", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "cname", HeadText = "投诉人", Width = 30, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "isHandle", HeadText = "处理状态", Width = 30, WidthType = SizeType.AutoSize, Format = (a) => { return (bool)a ? "已处理" : "待处理"; } });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "cdatetime", HeadText = "投诉时间", Width = 80, WidthType = SizeType.Absolute, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd HH:mm:ss"); } });
            this.ucDataGridView1.Columns = lstCulumns;
            this.ucDataGridView1.IsShowCheckBox = true;
            string sql = " select * from complaint";
            DataTable dt = new DataTable();
            dt = DBHelper.ExecuteQuery(sql);
            this.ucDataGridView1.DataSource = dt;
            this.ucDataGridView1.First();
        }

        private void btnHandle_Click(object sender, EventArgs e)
        {
            string id = (ucDataGridView1.SelectRow.DataSource as DataRow)["cid"].ToString();
            string carproblem = (ucDataGridView1.SelectRow.DataSource as DataRow)["carproblem"].ToString();
            admin_comFrm comFrm = new admin_comFrm();
            comFrm.cid = id;
            comFrm.carproblem = carproblem;
            DialogResult dr = comFrm.ShowDialog();
           
            if (dr == DialogResult.OK)
            {
                ucDataGridView1_Load(null, null);
            }

        }
    }
}
